{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAGstJREFUeJzt3X2MXNdZx/Hvk/W23QTKNs22StY1\nTqXI5sUkblclYKlqHIpbGiWWKZDQQoCiCFFBKWBqCwQUtdjIoBb+oMi0QFBKmpCkTksBE8WpkCKc\nao3TumljEtrG9jrUixIXkSzN2nn4Y+5k17t3Zu7MfTv33N9Hsnbn7uzsmbve557znOeca+6OiIjE\n66K6GyAiIuVSoBcRiZwCvYhI5BToRUQip0AvIhI5BXoRkcgp0IuIRE6BXkQkcgr0IiKRW1N3AwAu\nu+wyX79+fd3NEBFplCNHjvy3u08Nel4QgX79+vXMzs7W3QwRkUYxs6eyPE+pGxGRyA0M9Gb2V2Z2\nxsy+vOzYPjN73My+ZGafNrPJZV/bbWZPmtlxM9tWVsNFRCSbLD36vwHetuLYA8D3u/sPAP8B7AYw\ns+8Fbga+L/mePzezscJaKyIiQxsY6N39X4FnVhz7F3c/lzw8DKxNPr8J+JS7f9vdvw48CbypwPaK\niMiQisjR/wLwT8nn08DJZV87lRwTEZGa5Kq6MbPfBs4Bn+weSnla6p1NzOw24DaAdevW5WmGiMhQ\nDhydY9/B45w+u8AVkxPs3LaB7Zvj7ZOO3KM3s1uBG4B3+dJtqk4Br1v2tLXA6bTvd/f97j7j7jNT\nUwPLQEVECnHg6By77zvG3NkFHJg7u8Du+45x4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AvIhI5BXoRkcgp0IuIRE6BXkQkcv8P16YYQ+8fCuoA\nAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2020272dcc0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(100,)\n"
     ]
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = np.genfromtxt(\"data.csv\", delimiter=\",\")\n",
    "x_data = data[:,0]\n",
    "y_data = data[:,1]\n",
    "plt.scatter(x_data,y_data)\n",
    "plt.show()\n",
    "print(x_data.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 数据中心化\n",
    "def zeroMean(dataMat):\n",
    "    # 按列求平均，即各个特征的平均\n",
    "    meanVal = np.mean(dataMat, axis=0) \n",
    "    newData = dataMat - meanVal\n",
    "    return newData, meanVal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "newData,meanVal=zeroMean(data)  \n",
    "# np.cov用于求协方差矩阵，参数rowvar=0说明数据一行代表一个样本\n",
    "covMat = np.cov(newData, rowvar=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 94.99190951, 125.62024804],\n",
       "       [125.62024804, 277.49520751]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 协方差矩阵\n",
    "covMat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# np.linalg.eig求矩阵的特征值和特征向量\n",
    "eigVals, eigVects = np.linalg.eig(np.mat(covMat))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 30.97826888, 341.50884814])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 特征值\n",
    "eigVals"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[-0.89098665, -0.45402951],\n",
       "        [ 0.45402951, -0.89098665]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 特征向量\n",
    "eigVects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1], dtype=int64)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对特征值从小到大排序\n",
    "eigValIndice = np.argsort(eigVals)\n",
    "eigValIndice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "top = 1\n",
    "# 最大的top个特征值的下标\n",
    "n_eigValIndice = eigValIndice[-1:-(top+1):-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1], dtype=int64)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_eigValIndice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[-0.45402951],\n",
       "        [-0.89098665]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 最大的n个特征值对应的特征向量\n",
    "n_eigVect = eigVects[:,n_eigValIndice]\n",
    "n_eigVect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[ 44.02694787],\n",
       "        [  1.49722533],\n",
       "        [  3.35564513],\n",
       "        [  1.73205523],\n",
       "        [-17.84406034],\n",
       "        [ -7.68710859],\n",
       "        [ -7.6311404 ],\n",
       "        [ 16.4703207 ],\n",
       "        [ -1.92574891],\n",
       "        [ -0.35289859],\n",
       "        [ 17.26071108],\n",
       "        [-11.13030667],\n",
       "        [ 11.73358623],\n",
       "        [ -6.54975245],\n",
       "        [-11.27989566],\n",
       "        [ 10.70315359],\n",
       "        [ -7.11092921],\n",
       "        [-27.10646295],\n",
       "        [ 22.80011879],\n",
       "        [ 18.73367246],\n",
       "        [-17.75232043],\n",
       "        [-48.32951839],\n",
       "        [ 14.46601408],\n",
       "        [ 22.36856421],\n",
       "        [ -3.66790828],\n",
       "        [ -6.5367338 ],\n",
       "        [-24.03511973],\n",
       "        [-26.696945  ],\n",
       "        [ -4.62040617],\n",
       "        [-10.25663202],\n",
       "        [  6.87141913],\n",
       "        [ 33.98731832],\n",
       "        [ -0.49795028],\n",
       "        [-25.59431857],\n",
       "        [ -5.08219623],\n",
       "        [  7.07400117],\n",
       "        [-10.3589004 ],\n",
       "        [ 26.81843789],\n",
       "        [ 15.13930397],\n",
       "        [ 15.74751369],\n",
       "        [ 19.86509486],\n",
       "        [ 15.18178022],\n",
       "        [ -9.56831765],\n",
       "        [ 12.3873416 ],\n",
       "        [-44.24922602],\n",
       "        [ 31.5989945 ],\n",
       "        [ 20.60936247],\n",
       "        [-15.69205803],\n",
       "        [ 24.68142619],\n",
       "        [-25.71953206],\n",
       "        [ -1.70011545],\n",
       "        [  8.82426933],\n",
       "        [ 10.18596708],\n",
       "        [  9.92767378],\n",
       "        [ -1.59054221],\n",
       "        [ -1.35713786],\n",
       "        [ -2.23178334],\n",
       "        [-18.42859066],\n",
       "        [-10.81013855],\n",
       "        [ 15.48471562],\n",
       "        [ 13.37698622],\n",
       "        [  2.01510615],\n",
       "        [-13.45929748],\n",
       "        [ 11.60631421],\n",
       "        [  9.47911818],\n",
       "        [ 29.10215592],\n",
       "        [-14.62799906],\n",
       "        [-24.1314861 ],\n",
       "        [ -2.92304672],\n",
       "        [ 23.86122122],\n",
       "        [ 27.79335708],\n",
       "        [  5.96631636],\n",
       "        [  1.4680452 ],\n",
       "        [ 15.95209101],\n",
       "        [-37.79638897],\n",
       "        [-10.36346217],\n",
       "        [-20.58776205],\n",
       "        [ 21.05647364],\n",
       "        [ -9.181336  ],\n",
       "        [ 29.38968703],\n",
       "        [-10.26417212],\n",
       "        [-12.86474835],\n",
       "        [ 21.79735392],\n",
       "        [ -8.94685441],\n",
       "        [-27.45655642],\n",
       "        [ -8.10672783],\n",
       "        [  1.83592538],\n",
       "        [  2.27166878],\n",
       "        [  1.30641927],\n",
       "        [ 15.10178496],\n",
       "        [ 12.23038321],\n",
       "        [-13.67232328],\n",
       "        [-46.52044765],\n",
       "        [-14.2546318 ],\n",
       "        [-31.2297683 ],\n",
       "        [ -8.32905498],\n",
       "        [  0.42750425],\n",
       "        [-11.625534  ],\n",
       "        [  6.16748059],\n",
       "        [ 27.99826548]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 低维特征空间的数据\n",
    "lowDDataMat = newData*n_eigVect\n",
    "lowDDataMat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "matrix([[ 28.96880808,  33.50762783],\n",
       "        [ 48.27855698,  71.40104277],\n",
       "        [ 47.43477956,  69.74521555],\n",
       "        [ 48.17193728,  71.19181247],\n",
       "        [ 57.06007136,  88.63387007],\n",
       "        [ 52.44851558,  79.58416168],\n",
       "        [ 52.42310436,  79.53429476],\n",
       "        [ 41.4803299 ,  58.06021471],\n",
       "        [ 49.83268829,  74.45086712],\n",
       "        [ 49.11856784,  73.04947849],\n",
       "        [ 41.12146934,  57.35598744],\n",
       "        [ 54.0118291 ,  82.65200519],\n",
       "        [ 43.6309471 ,  62.28058188],\n",
       "        [ 51.93212233,  78.57079254],\n",
       "        [ 54.07974691,  82.78528698],\n",
       "        [ 44.09879393,  63.19868361],\n",
       "        [ 52.18691313,  79.07079354],\n",
       "        [ 61.26547544,  96.88654713],\n",
       "        [ 38.6064148 ,  52.42044913],\n",
       "        [ 40.45270141,  56.04359851],\n",
       "        [ 57.01841873,  88.55213104],\n",
       "        [ 70.90136881, 115.79600617],\n",
       "        [ 42.39034424,  59.84602515],\n",
       "        [ 38.80235331,  52.80495849],\n",
       "        [ 50.62368004,  76.00310786],\n",
       "        [ 51.92621148,  78.55919309],\n",
       "        [ 59.87099499,  94.15002133],\n",
       "        [ 61.07954221,  96.52167211],\n",
       "        [ 51.05614219,  76.85177076],\n",
       "        [ 53.61515503,  81.87357274],\n",
       "        [ 45.83851443,  66.61270785],\n",
       "        [ 33.52709612,  42.45280371],\n",
       "        [ 49.18442558,  73.1787176 ],\n",
       "        [ 60.57891727,  95.53924668],\n",
       "        [ 51.2658085 ,  77.26321954],\n",
       "        [ 45.74653621,  66.43220996],\n",
       "        [ 53.66158789,  81.96469251],\n",
       "        [ 36.78197936,  48.84018045],\n",
       "        [ 42.08465077,  59.24613285],\n",
       "        [ 41.80850561,  58.70422611],\n",
       "        [ 39.93900226,  55.03551626],\n",
       "        [ 42.06536529,  59.20828708],\n",
       "        [ 53.30263999,  81.26029383],\n",
       "        [ 43.33412288,  61.69809458],\n",
       "        [ 69.04879568, 112.16052014],\n",
       "        [ 34.61146561,  44.58076835],\n",
       "        [ 39.6010828 ,  54.37238375],\n",
       "        [ 56.08299881,  86.71646474],\n",
       "        [ 37.75224573,  50.74422935],\n",
       "        [ 60.63576789,  95.65081023],\n",
       "        [ 49.73024404,  74.24983072],\n",
       "        [ 44.95186282,  64.8727444 ],\n",
       "        [ 44.33361186,  63.65948988],\n",
       "        [ 44.45088464,  63.88962576],\n",
       "        [ 49.68049456,  74.15220243],\n",
       "        [ 49.57452209,  73.94424227],\n",
       "        [ 49.97163695,  74.72353971],\n",
       "        [ 57.32546537,  89.15467878],\n",
       "        [ 53.86646332,  82.36673967],\n",
       "        [ 41.92782368,  58.93837568],\n",
       "        [ 42.88479502,  60.81633443],\n",
       "        [ 48.04342381,  70.93961788],\n",
       "        [ 55.06925964,  84.7271049 ],\n",
       "        [ 43.68873236,  62.39397956],\n",
       "        [ 44.65454212,  64.28928282],\n",
       "        [ 35.745104  ,  46.80541819],\n",
       "        [ 55.59988464,  85.76840241],\n",
       "        [ 59.91474817,  94.23588248],\n",
       "        [ 50.28549092,  75.33944616],\n",
       "        [ 38.12464298,  51.47502102],\n",
       "        [ 36.33933729,  47.97154048],\n",
       "        [ 46.24945779,  67.41914234],\n",
       "        [ 48.29180562,  71.42704188],\n",
       "        [ 41.71562146,  58.52195044],\n",
       "        [ 66.11901726, 106.41112849],\n",
       "        [ 53.66365907,  81.96875698],\n",
       "        [ 58.30579289,  91.07847166],\n",
       "        [ 39.39808114,  53.97401367],\n",
       "        [ 53.12693891,  80.91549835],\n",
       "        [ 35.61455639,  46.54923181],\n",
       "        [ 53.61857845,  81.88029087],\n",
       "        [ 54.79931679,  84.19736957],\n",
       "        [ 39.06169964,  53.31389924],\n",
       "        [ 53.02047735,  80.70657838],\n",
       "        [ 61.4244282 ,  97.19847574],\n",
       "        [ 52.63903509,  79.95803681],\n",
       "        [ 48.12477717,  71.09926555],\n",
       "        [ 47.92693681,  70.711024  ],\n",
       "        [ 48.36518856,  71.57104842],\n",
       "        [ 42.1016855 ,  59.27956179],\n",
       "        [ 43.40538662,  61.83794241],\n",
       "        [ 55.16597964,  84.91690805],\n",
       "        [ 70.07999731, 114.18414829],\n",
       "        [ 55.43036489,  85.43573717],\n",
       "        [ 63.13757772, 100.56035714],\n",
       "        [ 52.73997818,  80.15612733],\n",
       "        [ 48.76424192,  72.35414998],\n",
       "        [ 54.23667692,  83.09324613],\n",
       "        [ 46.1581233 ,  67.23990769],\n",
       "        [ 36.24630282,  47.78896982]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 利用低纬度数据来重构数据\n",
    "reconMat = (lowDDataMat*n_eigVect.T) + meanVal\n",
    "reconMat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3X+UXGWd5/H3N90d6EaxoRMc07E7\ncQ8b1shAMHrcydE1CU6QH7E3o65Ooxl0J0uiDuIYSCZnV5wzOQkTFeLxEGwVDFAiDGKIgEQk4ag5\nC9qxcWIiWRnzg3SiBKFRSQud5Nk/blVS3X2r6lbVrbo/6vM6J6e7bt+ufup2+lvP/T7f53nMOYeI\niKTXhKgbICIitaVALyKScgr0IiIpp0AvIpJyCvQiIimnQC8iknIK9CIiKadALyKScgr0IiIp1xx1\nAwAmTZrkpk2bFnUzREQSZceOHc875yaXOi8WgX7atGn09/dH3QwRkUQxs/1BzlPqRkQk5UoGejO7\nzcyeM7Nf5h1bZ2ZPm9m/m9l3zaw972srzewZM9tjZgtq1XAREQkmSI/+m8AlY449CrzFOfeXwP8D\nVgKY2ZuBDwEzs99zi5k1hdZaEREpW8lA75z7EfDCmGM/cM4dyz58Apia/fx9wLedc6845/YCzwBv\nD7G9IiJSpjBy9B8Dvp/9vBN4Nu9rB7PHREQkIlVV3ZjZKuAYkMkd8jnNd2cTM1sCLAHo6uqqphki\nIr42DQyybsseDg0NM6W9leULZt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C8Ndh3M7Awze23uc+CvgV8Cm/FePzTAdXDO/RZ41sxyO9vPB3bTYNch68OcSttATK6BJkyVwcz+\nEm9ApQnvTfJe59w/m9mb8Hq2ZwMDwJXOuVeia2n9mNm7gc865y5vtOuQfb3fzT5sBr7lnFttZh3A\nvUAXcAD4gHPuhYiaWRdmdiHewPxE4DfAVWT/RmiQ62BmbcCzwJuccy9lj8Xi/4ICvYhIyil1IyKS\ncgr0IiIpp0AvIpJyCvQiIimnQC8iknIK9CIiKadALyKScgr0IiIp9/8BXtqajabGK1kAAAAASUVO\nRK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x202047fe860>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 载入数据\n",
    "data = np.genfromtxt(\"data.csv\", delimiter=\",\")\n",
    "x_data = data[:,0]\n",
    "y_data = data[:,1]\n",
    "plt.scatter(x_data,y_data)\n",
    "\n",
    "# 重构的数据\n",
    "x_data = np.array(reconMat)[:,0]\n",
    "y_data = np.array(reconMat)[:,1]\n",
    "plt.scatter(x_data,y_data,c='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
